#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> sortArrayByParity(vector<int>& nums) {
        for (int i = 0; i < nums.size(); ++i)
        {
            if (nums[i] % 2)
            {
                for (int j = i + 1; j < nums.size(); ++j)
                {
                    if (nums[j] % 2 == 0)
                    {
                        Swap(nums[i], nums[j]);
                        break;
                    }
                }
            }
        }

        return nums;
    }
    void Swap(int& a, int& b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }
};